/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.nifi.processors.huawei.obs;

import org.apache.nifi.components.AllowableValue;

import java.util.ArrayList;
import java.util.List;

public enum OBSRegions {
    NOT_FOUND("NotFound", "NotFound", "Not found"),
    OF_SOUTH_1("af-south-1", "obs.af-south-1.myhuaweicloud.com", "Africa - Johannesburg"),
    CN_NORTH_4("cn-north-4", "obs.cn-north-4.myhuaweicloud.com", "North China - Beijing IV"),
    CN_NORTH_1("cn-north-1", "obs.cn-north-1.myhuaweicloud.com", "North China - Beijing I"),
    CN_NORTH_9("cn-north-9", "obs.cn-north-9.myhuaweicloud.com", "North China - Ulanqabu I"),
    CN_EAST_2("cn-east-2", "obs.cn-east-2.myhuaweicloud.com", "East China - Shanghai II"),
    CN_EAST_3("cn-east-3", "obs.cn-east-3.myhuaweicloud.com", "East China - Shanghai I"),
    CN_SOUTH_1("cn-south-1", "obs.cn-south-1.myhuaweicloud.com", "South China - Guangzhou"),
    LA_NORTH_2("la-north-2", "obs.la-north-2.myhuaweicloud.com", "Latin America - Mexico City II"),
    NA_MEXICO_1("na-mexico-1", "obs.na-mexico-1.myhuaweicloud.com", "Latin America - Mexico City I"),
    SA_BRAZIL_1("sa-brazil-1", "obs.sa-brazil-1.myhuaweicloud.com", "Latin America - Sao Paulo I"),
    CN_SOUTHWEST_2("cn-southwest-2", "obs.cn-southwest-2.myhuaweicloud.com", "Southwest - Guiyang I"),
    AP_SOUTHWEST_2("ap-southeast-2", "obs.ap-southeast-2.myhuaweicloud.com", "Asia Pacific - Bangkok"),
    AP_SOUTHWEST_3("ap-southeast-3", "obs.ap-southeast-3.myhuaweicloud.com", "Asia Pacific - Singapore"),
    AP_SOUTHWEST_1("ap-southeast-1", "obs.ap-southeast-1.myhuaweicloud.com", "China - Hong Kong");

    public static final OBSRegions DEFAULT_REGION = CN_NORTH_1;
    private final String name;

    private final String endpoint;

    private final String description;

    OBSRegions(String name, String endpoint, String description) {
        this.name = name;
        this.endpoint = endpoint;
        this.description = description;
    }

    public String getName() {
        return this.name;
    }

    public String getEndpoint() {
        return this.endpoint;
    }

    public String getDescription() {
        return this.description;
    }

    public static OBSRegions fromName(String regionName) {
        OBSRegions[] var1 = values();
        int var2 = var1.length;

        for (int var3 = 0; var3 < var2; ++var3) {
            OBSRegions region = var1[var3];
            if (region.getName().equals(regionName)) {
                return region;
            }
        }

        throw new IllegalArgumentException("Cannot create enum from " + regionName + " value!");
    }

    public static AllowableValue[] getAvailableOBSRegions() {
        final List<AllowableValue> values = new ArrayList<>();
        for (final OBSRegions region : OBSRegions.values()) {
            AllowableValue allowableValue = new AllowableValue(region.getName(), region.getDescription(), "Huawei Obs Region Code : " + region.getName());
            values.add(allowableValue);
        }
        return values.toArray(new AllowableValue[0]);
    }
}
